home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 1 (Walnut Creek)
/
Aminet - June 1993 [Walnut Creek].iso
/
aminet
/
mus
/
play
/
multiplsr.lha
/
prefswin.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-09-14
|
10KB
|
431 lines
/*
* MultiPlayer
* Copyright (C) 1992 Bryan Ford
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* I (the author of MultiPlayer) can be contacted on the Internet at
* "bryan.ford@m.cc.utah.edu". See "Player.doc" for other addresses.
*
* $Id: prefswin.c,v 5.1 92/09/14 18:39:04 BAF Exp $
*
* $Log: prefswin.c,v $
* Revision 5.1 92/09/14 18:39:04 BAF
* Added nasty audio gadget support
*
* Revision 4.5 92/07/21 19:18:35 BAF
* Updated progsave() calling convention
*
* Revision 4.4 92/07/19 18:08:05 BAF
* Adjustment for putting localdata back into RemindNodes
*
* Revision 4.3 92/07/12 08:25:56 BAF
* end() waits with an EasyRequester as necessary until font requester comes down
*
* Revision 4.2 92/06/21 11:13:07 BAF
* Migrated regargs to stdargs
*
* Revision 4.1 92/06/06 19:56:10 BAF
* Major_code_cleanup
*
* Revision 3.1 92/05/25 07:53:08 BAF
* GNU-ized.
*
*
*/
/* System includes */
#include <exec/types.h>
#include <dos/dos.h>
#include <intuition/intuition.h>
#include <libraries/asl.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/intuition.h>
#include <string.h>
#include "bry/macros.h"
#include "bry/remind.h"
#include "bry/misc.h"
#include "bry/guido.h"
#include "player.h"
extern GuidoSpec prefswinspec, prefswinfontspec;
extern short prefswinleft;
struct Gadget
*prefswinmainfontgad, *prefswinmainfontsizegad,
*prefswinlistfontgad, *prefswinlistfontsizegad,
*prefswinshowgad, *prefswinplaygad,
*prefswinspectrumgad, *prefswinscopegad,
*prefswinqscopegad, *prefswinnotegad,
*prefswinpausefadegad,
*prefswinkeepgad, *prefswinnastygad,
*prefswinicongad, *prefswiniconagad,
*prefswincontgad, *prefswinhotkeygad;
void prefswinupdate(void);
static long check(long sigmask);
static long close(int remake);
static struct MPWin mpwin = {prefswinspec,&prefswinleft,prefswinupdate,
{0},{{0},check},{{0},close}};
void *fontreq;
char whichfont;
static long
check(long sigmask)
{
if((sigmask & mpwin.sigmask) && GCheckPanel(mpwin.win,standardcallback,0L))
setfinmpwin(&mpwin);
return(0);
}
static long
close(int remake)
{
closempwin(&mpwin);
if(remake)
showerr(openmpwin(&mpwin));
return(0);
}
static void
fontprefsupdate(void)
{
extern char mainfontname[], listfontname[];
extern short mainfontsize, listfontsize;
struct Window *win;
if(win = mpwin.win)
{
GSetText(win,prefswinmainfontgad,mainfontname);
GSetNumber(win,prefswinmainfontsizegad,mainfontsize);
GSetText(win,prefswinlistfontgad,listfontname);
GSetNumber(win,prefswinlistfontsizegad,listfontsize);
}
}
void
prefswinupdate(void)
{
extern char pausefade, keepprog, nasty_audio, appicon, appicona, contprogonerr, stopfade, hotkey[];
extern struct Library *CxBase;
struct Window *win;
if(win = mpwin.win)
{
GSetCycleActive(win,prefswinplaygad,playmode);
GSetCycleActive(win,prefswinshowgad,showmode);
GSetCheckboxChecked(win,prefswinspectrumgad,flashflags & FF_SPECTRUM);
GSetCheckboxChecked(win,prefswinscopegad,flashflags & FF_SCOPE);
GSetCheckboxChecked(win,prefswinqscopegad,flashflags & FF_QSCOPE);
GSetCheckboxChecked(win,prefswinnotegad,flashflags & FF_NOTES);
GSetCheckboxChecked(win,prefswinpausefadegad,pausefade);
GSetCheckboxChecked(win,prefswinkeepgad,keepprog);
GSetCheckboxChecked(win,prefswinnastygad,nasty_audio);
GSetCheckboxChecked(win,prefswinicongad,appicon);
GSetCheckboxChecked(win,prefswiniconagad,appicona);
GSetCheckboxChecked(win,prefswincontgad,contprogonerr);
GEnDisGadget(win,CxBase,prefswinhotkeygad);
GSetString(win,prefswinhotkeygad,hotkey);
fontprefsupdate();
}
}
static void
prefschanged(void)
{
extern char hotkey[], prefsglob[];
if(mpwin.win)
strcpy(hotkey,GGetString(prefswinhotkeygad));
GlobPostMod(prefsglob,prefswinupdate);
sysflags |= SF_WINDOWUP;
}
void
gui_prefswinplay(struct GuidoMessage *im)
{
playmode = im->Code;
prefschanged();
}
void
gui_prefswinshow(struct GuidoMessage *im)
{
showmode = im->Code;
prefschanged();
}
static void
setflash(struct Gadget *gad,char flagbit)
{
extern char *flashywinopenclose(void);
if(GGetCheckboxChecked(gad))
flashflags |= flagbit;
else
flashflags &= ~flagbit;
flashywinopenclose();
prefschanged();
}
void
gui_prefswinspectrogram(struct GuidoMessage *im)
{
setflash(prefswinspectrumgad,FF_SPECTRUM);
}
void
gui_prefswinscope(struct GuidoMessage *im)
{
setflash(prefswinscopegad,FF_SCOPE);
}
void
gui_prefswinqscope(struct GuidoMessage *im)
{
setflash(prefswinqscopegad,FF_QSCOPE);
}
void
gui_prefswinnote(struct GuidoMessage *im)
{
setflash(prefswinnotegad,FF_NOTES);
}
void
gui_prefswinpausefade(struct GuidoMessage *gm)
{
extern char pausefade;
pausefade = GGetCheckboxChecked(prefswinpausefadegad);
prefschanged();
}
void
gui_prefswinkeep(struct GuidoMessage *gm)
{
extern char keepprog;
keepprog = GGetCheckboxChecked(prefswinkeepgad);
prefschanged();
}
void
gui_prefswinnasty(struct GuidoMessage *gm)
{
extern char nasty_audio;
nasty_audio = GGetCheckboxChecked(prefswinnastygad);
prefschanged();
}
void
gui_prefswinicon(struct GuidoMessage *gm)
{
extern char appicon;
appicon = GGetCheckboxChecked(prefswinicongad);
prefschanged();
}
void
gui_prefswinicona(struct GuidoMessage *gm)
{
extern char appicona;
appicona = GGetCheckboxChecked(prefswiniconagad);
prefschanged();
}
void
gui_prefswincont(struct GuidoMessage *gm)
{
extern char contprogonerr;
contprogonerr = GGetCheckboxChecked(prefswincontgad);
prefschanged();
}
void
gui_prefswinhotkey(struct GuidoMessage *gm)
{
prefschanged();
}
/* Check to see if the font requester has been closed */
static long
fontcheck(void)
{
struct TextAttr *attr;
long count;
if(fontreq && ((count = GCheckRequester(fontreq,&attr)) >= 0))
{
extern char mainfontname[], listfontname[];
extern short fontreqleft, mainfontsize, listfontsize;
GGetRequesterLocation(fontreq,&fontreqleft);
if(count)
{
if(whichfont == 0)
{
mainfontsize = attr->ta_YSize;
strncpy(mainfontname,attr->ta_Name,30);
}
else
{
listfontsize = attr->ta_YSize;
strncpy(listfontname,attr->ta_Name,30);
}
fontprefsupdate();
prefschanged();
}
}
return(0);
}
static struct RemindNode fontchecknode = {{0},fontcheck};
static long
fontend(void)
{
if(fontreq)
{
while(GDeleteRequester(fontreq))
{
static struct EasyStruct easy = {
sizeof(easy),0,"MultiPlayer","Please close all file and font requesters","OK"};
EasyRequestArgs(0,&easy,0,0);
}
fontreq = 0L;
}
remind_rem(&fontchecknode);
return(0);
}
static struct RemindNode fontendnode = {{0},fontend,-100};
static void
addfontcalls(void)
{
addcalls(&fontchecknode,0,0,&fontendnode);
}
static void
openfontreq(int which,char *hailtext,char *font,int size)
{
struct {
struct Window *win;
char *hailtext;
int fixedwidth;
char *font;
int size;
} parms;
int rc;
parms.fixedwidth = whichfont = which;
parms.hailtext = hailtext;
parms.font = font;
parms.size = size;
parms.win = mpwin.win;
if(!fontreq && !(fontreq = GCreateRequester(prefswinfontspec)))
showerr("Font requester unavailable");
else
{
if((rc = GOpenRequester(fontreq,prefswinfontspec,&parms)) == 0)
showerr("Font requester in use");
else if(rc < 0)
showerr("Not enough memory");
addfontcalls();
}
}
void gui_prefswinmainfont(struct GuidoMessage *gm)
{
extern char mainfontname[], listfontname[];
extern short mainfontsize, listfontsize;
openfontreq(0,"Select font for control panels",mainfontname,mainfontsize);
}
void gui_prefswinlistfont(struct GuidoMessage *gm)
{
extern char mainfontname[], listfontname[];
extern short mainfontsize, listfontsize;
openfontreq(1,"Select font for listings",listfontname,listfontsize);
}
static char *
save(char *filename)
{
BPTR han;
char *err = "Error saving preferences";
extern char prefs[], prefsend[];
remind_call(&snaplist,0L);
if(!(han = Open(filename,MODE_NEWFILE)))
goto err1;
if(Write(han,prefs,(long)(prefsend-prefs)) <= 0)
goto err2;
err = 0L;
err2:
Close(han);
err1:
return(err);
}
void
gui_prefswinsave(void)
{
extern char keepprog;
if(!showerr(save("ENV:MultiPlayerPrefs")) &&
!showerr(save("ENVARC:MultiPlayerPrefs")) &&
(!keepprog || (!showerr(progsave(0,"ENV:MultiPlayerProgram")) &&
!showerr(progsave(0,"ENVARC:MultiPlayerProgram")))))
showerr("Preferences saved");
}
void
gui_prefswinok(void)
{
setfinmpwin(&mpwin);
}
char *
prefswinopenclose(void)
{
if(mpwin.win)
{
setfinmpwin(&mpwin);
return(0L);
}
return(openmpwin(&mpwin));
}
void
gui_prefswinopenclose(void)
{
showerr(prefswinopenclose());
}